#!/usr/bin/python3
# -*- coding: utf-8 -*-
"""
@File Name  : mp4_upload.py
@Author     : LeeCQ
@Date-Time  : 2019/12/7 15:42

尝试上传mp4 data
"""
import os
from MOOC.life_and_heart.mp4_info_sql import LifeAndHeartDB


class UploadDAta(LifeAndHeartDB):
    """
    上传MP4文件；
    """
    PATH = r'C:\Users\LCQ\Downloads\Video\lifeAndHeart'

    def upload(self):
        os.chdir(self.PATH)
        file = os.listdir('.')[0]
        id_ = file[:3]
        with open(file, 'rb') as fb:
            data = fb.read()
            self.update(self.table_name, 'ID', id_, MediumData=data)
            print(id_ ,len(data)/1024**2, 'Mb')


if __name__ == '__main__':
    UploadDAta().upload()
